Garbage collection is the reclamation of unused memory space used to store objects dynamically allocated at runtime. The objects may represent variables, data structures, classes, object types, and other types of data that are stored in a heap. A garbage collector scans the objects in the heap and marks those objects that are ‘live’ and still in use by a program. The garbage collector then reclaims the memory space of the unmarked objects which are presumed to be ‘dead’ or garbage.
A generational or ephemeral garage collector may be used to boost the performance of the garbage collection process by marking only the recently allocated objects. A generational garage collector relies on the assumption that most dynamically-allocated objects die young and that collecting recently allocated objects will probably reclaim more unused memory space. For this reason, a generational garbage collector segregates the heap into two or more generations.
A younger generation stores newly allocated objects and an older generation stores objects that are considered ‘live.’ Objects in the older generation are often not collected by the garbage collector. Objects from the younger generation are processed by the garbage collector and promoted to the older generation after the garbage collector has marked them as being ‘live.’ The ‘live’ objects from the younger generation are then copied into the older generation's memory space. Each generation typically consumes a contiguous address space so copying objects from the younger generation's memory space into the older generation's memory space burdens the computational overhead of the generational garbage collection. Furthermore, the allocation of a contiguous address space creates fragmentation problems within the heap when objects are de-allocated.